<template>
	<view class="page">
		<view class="card">
			<view class="card-title">问题描述</view>
			<tn-input v-model="content" :type="type"
				:customStyle="{background:'#F7F7F7',borderRadius:'20rpx',padding:'24rpx'}"
				placeholder="请详细描述问题以便我们尽快处理~" :height="height" :autoHeight="autoHeight" />
		</view>
		<view class="card">
			<view class="card-title">*上传凭证</view>
			<view class="card-item" @click="uploadfun('imgs')">
				<image src="@/static/img/add.png" v-if="!imgs" class="add" mode=""></image>
				<image class="addimg" :src="apifun.URLimg+imgs" v-else mode="aspectFit"></image>
			</view>
		</view>
		<view class="card">
			<view class="card-title">*联系方式</view>
			<input type="number" placeholder="请输入手机号~" maxlength="11" v-model="mobile" />
			<view class="card-tips">授权的手机号仅用于联系您了解详细情况和反馈处理结果</view>
		</view>
		<view class="btn" @click="submit">提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				mobile: '',
				imgs: '',
				type: 'textarea',
				height: 228,
				autoHeight: true,
			};
		},
		onLoad() {

		},
		methods: {
			submit() {
				let sendData = {
					img:this.imgs,
					content:this.content,
					mobile:this.mobile
				};
				if(this.content == ''){
					this.apifun.toast('请输入您要反馈的内容');
					return false
				};
				this.apifun.unirequest('/partner/user/feedback','post',sendData,(res)=>{
					if(res.code === 200){
						let datas = res.data;
						this.apifun.toast('反馈成功');
						setTimeout(()=>{
							this.apifun.goback()
						},1500)
					}else{
						this.apifun.toast(res.msg)
					}
				})
			},
			uploadfun(type) {
				this.apifun.uploadFileimg(res => {
					if (res.code == 200) {
						this[type] = res.data.src
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		padding: 20rpx 30rpx;
		box-sizing: border-box;
	}

	.card {
		border-radius: 20rpx;
		background: #FFFFFF;
		padding: 30rpx;
		box-sizing: border-box;
		margin-bottom: 20rpx;

		.card-title {
			font-size: 32rpx;
			font-weight: bold;
			padding-bottom: 20rpx;
			border-bottom: 2rpx solid #F7F7F7;
		}

		input {
			width: 630rpx;
			height: 88rpx;
			padding: 0 24rpx;
			line-height: 88rpx;
			border-radius: 20rpx;
			font-size: 28rpx;
			background: #F7F7F7;
		}

		.card-tips {
			margin-top: 22rpx;
			font-size: 24rpx;
			color: #666666;
		}

		.card-item {
			position: relative;
			margin-top: 24rpx;
			width: 200rpx;
			height: 140rpx;
			border-radius: 20rpx;
			background: #F7F7F7;
			text-align: center;

			.add {
				margin: 46rpx 0;
				width: 50rpx;
				height: 50rpx;
			}
			.addimg{
				position: absolute;
				top: 0;
				left: 0;
				z-index: 10;
				width: 200rpx;
				height: 140rpx;
			}
		}
	}

	.btn {
		margin-top: 110rpx;
		width: 550rpx;
	}
</style>